package cn.fan.config.mq;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FundDirectMessageConfig {
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("fund.direct");
    }

    @Bean
    public Queue directQueue(){
        return QueueBuilder
                .durable("fund.queue")
                .ttl(10000)
                .deadLetterExchange("error.direct")
                .deadLetterRoutingKey("error")
                .build();
    }

    @Bean
    public Binding directBinding(){
        return BindingBuilder
                .bind(directQueue())
                .to(directExchange())
                .with("fund");
    }

    @Bean
    public Queue synchroAllQueue(){
        return QueueBuilder
                .durable("synchroAll.queue")
                .ttl(10000)
                .deadLetterExchange("error.direct")
                .deadLetterRoutingKey("error")
                .build();
    }

    @Bean
    public Binding synchroAllBinding(){
        return BindingBuilder
                .bind(synchroAllQueue())
                .to(directExchange())
                .with("all");
    }
}
